# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=('libpipeline' 'libpipeline-devel')
pkgver=1.4.0
pkgrel=1
pkgdesc="a C library for manipulating pipelines of subprocesses in a flexible and convenient way"
url="http://libpipeline.nongnu.org/"
groups=('libraries')
arch=('i686' 'x86_64')
license=('BSD')
makedepends=('openssl-devel' 'zlib-devel')
options=('!libtool')
source=(http://download.savannah.gnu.org/releases/libpipeline/libpipeline-$pkgver.tar.gz{,.sig}
        libpipeline-1.3.0-msys2.patch)
md5sums=('660f4ac9340834a231d1516746d03d28'
         'SKIP'
         'cb532f34d485ada4a636441739cbaeb4')

prepare() {
  cd "$pkgname-$pkgver"
  patch -p1 -i ${srcdir}/libpipeline-1.3.0-msys2.patch

  cp -rf build-aux/snippet ${srcdir}/
  autoreconf -fi
  cp -rf ${srcdir}/snippet build-aux/
}

build() {
  cd "$pkgname-$pkgver"

  ./configure --build=${CHOST} --prefix=/usr
  make
  make DESTDIR="${srcdir}/dest" install
}

check() {
  cd "$pkgname-$pkgver"
  make check
}

package_libpipeline() {
  depends=('gcc-libs')
  groups=('libraries')

  mkdir -p ${pkgdir}/usr/bin
  cp -f ${srcdir}/dest/usr/bin/*.dll ${pkgdir}/usr/bin/
  cp -rf ${srcdir}/dest/usr/share ${pkgdir}/usr/
}

package_libpipeline-devel() {
  pkgdesc="libpipeline headers and libraries"
  options=('staticlibs')
  depends=("libpipeline=${pkgver}")
  groups=('development')

  mkdir -p ${pkgdir}/usr
  cp -rf ${srcdir}/dest/usr/include ${pkgdir}/usr/
  cp -rf ${srcdir}/dest/usr/lib ${pkgdir}/usr/
}
